import { Poker } from "./Poker";
import { IUserVo, User } from "./User";

export interface IPlayerVo extends IUserVo {
  prepare: boolean
  cards: Array<Poker>
}

export class PlayerVo implements IPlayerVo {
  id: string;
  name: string;
  balance: number;
  prepare: boolean;
  cards: Poker[];

  constructor(player: IPlayerVo) {
    this.id = player.id
    this.name = player.name
    this.balance = player.balance
    this.prepare = player.prepare
    this.cards = player.cards
  }
}


/**
 * 玩家对象
 */
export default class Player extends User implements IPlayerVo {
  // 是否准备
  public prepare: boolean = false
  // 是否整理好牌
  public ready: boolean = false
  // 手牌
  public cards: Array<Poker> = []
  // 叫地主次数
  public callLandloardCount: number = 0

  constructor(user: IUserVo) {
    super(user)
  }

  /**
   * 是否准备
   * @returns 
   */
  public isPrepare(): boolean {
    return this.prepare
  }

  /**
   * 是否整理好牌
   * @returns 
   */
  public isReady(): boolean {
    return this.ready
  }

  /**
   * 初始化手牌（系统发牌时使用）
   * @param cards 
   */
  public initCards(cards: Array<Poker>) {
    this.cards = cards
  }

  public getVo(): PlayerVo {
    return new PlayerVo(this)
  }
}